<?php

namespace App\Http\Controllers\Backend;

use App\Http\Repositories\AboutMeRepository;
use App\Http\Controllers\Controller;
use App\Http\Requests\Backend\AboutMeRequest;

class AboutMeController extends Controller
{
    protected $aboutMeRepository;

    public function __construct(AboutMeRepository $aboutMeRepository)
    {
        $this->aboutMeRepository = $aboutMeRepository;
    }

    /**
     * 获取关于我的信息
     * @return \Illuminate\Http\JsonResponse
     */
    public function index()
    {
        return responseResult($this->aboutMeRepository->getInfo(), self::SUCCESS_CODE);
    }

    /**
     * 编辑关于我
     * @param AboutMeRequest $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function edit(AboutMeRequest $request)
    {
        $result = $this->aboutMeRepository->edit($request->all());
        return responseResult([], $result ? self::SUCCESS_CODE : self::ERROR_CODE);
    }
}
